import request from '@/utils/request'
import qs from 'qs'
import { api } from './api'

export function syncGoods (parameter) {
  return request({
    url: api.syncGoods,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}
export function batchDelivery (parameter) {
  return request({
    url: api.batchDelivery,
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    // data: qs.stringify(parameter)
    data: parameter
  })
}
export function delSync (parameter) {
  return request({
    url: api.delSync,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function progressTask (parameter) {
  return request({
    url: api.progressTask,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function statusTask (parameter) {
  return request({
    url: api.statusTask,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function getGoodsSelect (parameter) {
  return request({
    url: api.getGoodsSelect,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function getALlTaskLevel2 (parameter) {
  return request({
    url: api.getALlTaskLevel2,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function getGoodsList (parameter) {
  return request({
    url: api.getGoodsList,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function saveGoods (parameter) {
  return request({
    url: api.saveGoods,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function updateGoods (parameter) {
  return request({
    url: api.updateGoods,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function getPerformanceList (parameter) {
  return request({
    url: api.getPerformanceList,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function exportPerformance (parameter) {
  return request({
    url: api.exportPerformance,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    responseType: 'blob',
    data: qs.stringify(parameter)
  })
}

export function deleteGoods (parameter) {
  return request({
    url: api.deleteGoods,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function savePerformance (parameter) {
  return request({
    url: api.savePerformance,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function updatePerformance (parameter) {
  return request({
    url: api.updatePerformance,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function deletePerformance (parameter) {
  return request({
    url: api.deletePerformance,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function selectContractList (parameter) {
  return request({
    url: api.selectContract,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}
export function getContractInfo (id) {
  return request({
    url: `${api.getContractInfo}/${id}`,
    method: 'get'
  })
}
export function getContractList (parameter) {
  return request({
    url: api.getContractList,
    method: 'post',
    // config: 'x-www-form-urlencoded',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function saveContract (parameter) {
  return request({
    url: api.saveContract,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function updateContract (parameter) {
  return request({
    url: api.updateContract,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function deleteContract (parameter) {
  return request({
    url: api.deleteContract,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function getTaskList (parameter) {
  return request({
    url: api.getTaskList,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function saveTask (parameter) {
  return request({
    url: api.saveTask,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function updateTask (parameter) {
  return request({
    url: api.updateTask,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function deleteTask (parameter) {
  return request({
    url: api.deleteTask,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function getAllProjectType (parameter) {
  return request({
    url: api.getAllProjectType,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function getProjectTypeList (parameter) {
  return request({
    url: api.getProjectTypeList,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function saveProjectType (parameter) {
  return request({
    url: api.saveProjectType,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function updateProjectType (parameter) {
  return request({
    url: api.updateProjectType,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function delProjectType (parameter) {
  return request({
    url: api.delProjectType,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function getProjectList (parameter) {
  return request({
    url: api.getProjectList,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function saveProject (parameter) {
  return request({
    url: api.saveProject,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function updateProject (parameter) {
  return request({
    url: api.updateProject,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function delProject (parameter) {
  return request({
    url: api.delProject,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function delFileById (parameter) {
  return request({
    url: api.delFileById,
    method: 'post',
    params: parameter
  })
}

export function getFileByIds (parameter) {
  return request({
    url: api.getFileByIds,
    method: 'post',
    params: parameter
  })
}

export function getIncomeList (parameter) {
  return request({
    url: api.getIncomeList,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}
export function saveIncome (parameter) {
  return request({
    url: api.saveIncome,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function deleteIncomeReq (parameter) {
  return request({
    url: api.deleteIncomeReq,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function updateIncome (parameter) {
  return request({
    url: api.updateIncome,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function getRewardList (parameter) {
  return request({
    url: api.getRewardList,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function saveReward (parameter) {
  return request({
    url: api.saveReward,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}
export function deleteRewardReq (parameter) {
  return request({
    url: api.deleteRewardReq,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}
export function updateReward (parameter) {
  return request({
    url: api.updateReward,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}
export function allStaff (parameter) {
  return request({
    url: api.allStaff,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function updateInfo (parameter) {
  return request({
    url: api.updateInfo,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function deleteInfoReq (parameter) {
  return request({
    url: api.deleteInfoReq,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function saveInfo (parameter) {
  return request({
    url: api.saveInfo,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function getInfoList (parameter) {
  return request({
    url: api.getInfoList,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function updateProduct (parameter) {
  return request({
    url: api.updateProduct,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function deleteProductReq (proId) {
  return request({
    url: `${api.deleteProductReq}`,
    method: 'post',
    config: 'x-www-form-urlencoded',
    params: proId
  })
}

export function saveProduct (parameter) {
  return request({
    url: api.saveProduct,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function getproductList (parameter) {
  return request({
    url: api.getproductList,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function getExpressList (parameter) {
  return request({
    url: api.getExpressList,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}
export function getExpressInfo (expressId) {
  return request({
    url: `${api.getExpressInfo}/${expressId}`,
    method: 'post',
    config: 'x-www-form-urlencoded'
  })
}
export function saveExpress (parameter) {
  return request({
    url: api.saveExpress,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}
export function updateExpress (parameter) {
  return request({
    url: api.updateExpress,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function deleteExpress (parameter) {
  return request({
    url: api.deleteExpress,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function getCustomList (parameter) {
  return request({
    url: api.getCustomList,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}
export function getAllCustom (parameter) {
  return request({
    url: api.getAllCustom,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}
export function saveCustom (parameter) {
  return request({
    url: api.saveCustom,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}
export function updateCustom (parameter) {
  return request({
    url: api.updateCustom,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}
export function deleteCustom (parameter) {
  return request({
    url: api.deleteCustom,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function deleteContact (parameter) {
  return request({
    url: api.deleteContact,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function saveContact (parameter) {
  return request({
    url: api.saveContact,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function updateContact (parameter) {
  return request({
    url: api.updateContact,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function getContact (parameter) {
  return request({
    url: api.getContact,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function roleUpdate (parameter) {
  return request({
    url: api.roleUpdate,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function roleDelete (parameter) {
  return request({
    url: api.roleDelete,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function productList (parameter) {
  return request({
    url: api.productList,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function roleMenu (roleId) {
  return request({
    url: `${api.roleMenu}/${roleId}`,
    method: 'get'
    // config: 'x-www-form-urlencoded'
    // params: parameter
  })
}

export function addRole (parameter) {
  return request({
    url: api.addRole,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function menuList (parameter) {
  return request({
    url: api.menuList,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function getstaffInfo (userId) {
  return request({
    url: `${api.getstaffInfo}/${userId}`,
    method: 'get'
  })
}

export function roleSelect (parameter) {
  return request({
    url: api.roleSelect,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function supplierSave (parameter) {
  return request({
    url: api.supplierSave,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function supplierUpdate (parameter) {
  return request({
    url: api.supplierUpdate,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function supplierUpdateDiscount (parameter) {
  return request({
    url: api.supplierUpdateDiscount,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function supplierDelete (parameter) {
  return request({
    url: api.supplierDelete,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function supplierSelect (parameter) {
  return request({
    url: api.supplierSelect,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function supplierTypes (parameter) {
  return request({
    url: api.supplierTypes,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function supplierSelectLast (parameter) {
  return request({
    url: api.supplierSelectLast,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function supplierInfo (parameter) {
  return request({
    url: api.supplierInfo,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function addStaff (parameter) {
  return request({
    url: api.addStaff,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}
export function updateStaff (parameter) {
  return request({
    url: `${api.updateStaff}`,
    method: 'post',
    // config: 'x-www-form-urlencoded',
    // headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    // data: parameter
    params: parameter
  })
}
export function updateStaffPassword (parameter) {
  return request({
    url: api.updateStaffPassword,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}
export function getUserInfo (parameter) {
  return request({
    url: api.getUserInfo,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}
export function disableStaff (parameter) {
  return request({
    url: api.disableStaff,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}
export function getStafflist (parameter) {
  return request({
    url: api.getStafflist,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function getUserList (parameter) {
  return request({
    url: api.user,
    method: 'get',
    params: parameter
  })
}

// export function getRoleList (parameter) {
//   return request({
//     url: api.role,
//     method: 'get',
//     params: parameter
//   })
// }

export function getServiceList (parameter) {
  return request({
    url: api.service,
    method: 'get',
    params: parameter
  })
}

export function getPermissions (parameter) {
  return request({
    url: api.permissionNoPager,
    method: 'get',
    params: parameter
  })
}

export function getOrgTree (parameter) {
  return request({
    url: api.orgTree,
    method: 'get',
    params: parameter
  })
}

// id == 0 add     post
// id != 0 update  put
export function saveService (parameter) {
  return request({
    url: api.service,
    method: parameter.id === 0 ? 'post' : 'put',
    data: parameter
  })
}

export function saveSub (sub) {
  return request({
    url: '/sub',
    method: sub.id === 0 ? 'post' : 'put',
    data: sub
  })
}

export function saveFile (parameter) {
  return request({
    url: api.saveFile,
    method: 'post',
    data: parameter
  })
}

export function resetPassword (parameter) {
  return request({
    url: api.resetPassword,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function baseDataInfo (parameter) {
  return request({
    url: api.baseDataInfo,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function baseDataSave (parameter) {
  return request({
    url: api.baseDataSave,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function baseDataUpdate (parameter) {
  return request({
    url: api.baseDataUpdate,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function baseDataUpdateDiscount (parameter) {
  return request({
    url: api.baseDataUpdateDiscount,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}

export function baseDataDelete (parameter) {
  return request({
    url: api.baseDataDelete,
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(parameter)
  })
}
